import processing.core.*;

public class BackgroundRGBInvert extends PApplet {

  public static void main(String[] args) {
    PApplet.main(new String[] {"BackgroundRGBInvert"});
  }
  
  public void setup(){
    size(1024, 768); // we set the size of the canvas window
    PImage img = loadImage("files/Matterhorn.jpeg"); // we load the file
    background(img); // and set it as the background
    
    loadPixels(); // we load the pixels
    for(int i = 0; i < pixels.length; i++){
      // we get the red, green and blue color of the pixel
      int red = (int) red(pixels[i]);
      int green = (int) green(pixels[i]);
      int blue = (int) blue(pixels[i]);
      
      // we invert the colors
      red = 255 - red;
      green = 255 - green;
      blue = 255 - blue;
      
      // we set the color
      pixels[i] = color(red, green, blue);
    }
    
    // we update the pixels
    updatePixels();
  }
  
  public void draw(){}
}